package com.cx.webflux.config;

import com.cx.webflux.handler.TimeHandler;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.reactive.function.server.RouterFunction;
import static org.springframework.web.reactive.function.server.RequestPredicates.GET;
import static org.springframework.web.reactive.function.server.RouterFunctions.route;
/**
 * 路由器
 *
 * @author 旭旭
 * @create 2018-07-30 22:50
 **/
@Configuration
public class RouterConfig {
    @Autowired
    public TimeHandler timeHandler;

    @Bean
    public RouterFunction timeRouter(){
        return route(GET("/time"),req -> timeHandler.getTime(req))
                .andRoute(GET("/date"),timeHandler::getDate)
                .andRoute(GET("/times"),timeHandler::sendTimePerSec);
    }
}
